#ifndef MAINFORM_H
#define MAINFORM_H

#include <QMainWindow>
#include <QSystemTrayIcon>

enum BASEMENU//类型列表
{
    base_sw = 0     ,
    base_name       ,
    base_ip         ,
    base_type       ,
    base_local      ,
    base_remote     ,
    base_encryption ,
    base_compression,
    base_length,
};
enum XTCPMENU//类型列表
{
    xtcp_sw = 0     ,
    xtcp_sORc       ,  //服务端或客户端
    xtcp_ip         ,
    xtcp_port       ,
    xtcp_name       ,
    //xtcp_sk       ,
    xtcp_encryption ,
    xtcp_compression,
    xtcp_length     ,
};

QT_BEGIN_NAMESPACE
namespace Ui { class MainForm; }
QT_END_NAMESPACE

class FrpConfig;
class debugForm;
class TableView;
class QSettings;
class baseForm ;
class QProcess ;
class xtcpForm ;
class QPixmap  ;
class QAction  ;
class QTimer   ;
class QLabel   ;
class debugForm;
class QMenu    ;

class MainForm : public QMainWindow
{
    Q_OBJECT

public:
    MainForm(QWidget *parent = nullptr);
    ~MainForm();
    QString result;
    qint8 runState = 0;
    QString debugTmp;
    void closeEvent( QCloseEvent *event );

private:
    baseForm  *baseform    = nullptr;
    debugForm *debugform   = nullptr;
    xtcpForm  *xtcpform    = nullptr;
    FrpConfig *frpConfig   = nullptr;
    QSettings *settings    = nullptr;
    QProcess  *process     = nullptr;
    QLabel *statusLabel    = nullptr;
    QPixmap *image         = nullptr;
    QSystemTrayIcon *micon = nullptr;
    QAction *mShow         = nullptr;
    QAction *miconExit     = nullptr;
    QAction *miconShow     = nullptr;
    QTimer *m_timer        = nullptr;
    QMenu *m_menu          = nullptr;
private:
    void getApplicationCfg();
    qint8 getRdNum(TableView *tmp);
    void updateFrpConfig();
    void getXtcpCfg();
    void getBaseCfg();
    void fileStarInit();
    void APPclrear();
    void pageInit();
    void passwordMode();
    void saveData();
    void recData();
    void setProcessAutoRun(const QString &appPath,bool flag);
    void on_activatedSysTrayIcon(QSystemTrayIcon::ActivationReason reason);
    void creatMenu();

public slots:
    void on_startButton_clicked();

    void on_ResetButton_clicked();

private slots:
    void on_mainPushButton_clicked();

    void on_basePushButton_clicked();

    void on_xtcpPushButton_clicked();

    void on_debugPushButton_clicked();

    void on_m_Timeout();

private:
    Ui::MainForm *ui;
    struct FRPCOMMON
    {
        QString addr;  //地址
        QString port;  //端口
        QString token; //token
    };

    struct FRPBASE
    {
        QString name;                       //组名
        QString ip;                         //ip
        QString type;
        QString localPort;                  //转发端口
        QString remotePort;                 //远程端口
        QString use_encryption  = "false";  //加密
        QString use_compression = "false";  //压缩

    };
    struct FRPXTCP
    {
        QString name;
        QString ip  ;
        QString sORc;                       //客户单 or 服务端
        QString port;
        QString sk;
        QString use_encryption  = "false";
        QString use_compression = "false";

    };
public:

    FRPCOMMON frpCommon;
    FRPBASE frpBase[50];
    FRPXTCP frpXtcp[50];
};
#endif // MAINFORM_H
